<?php

namespace Wechat;

use EasyWeChat\Kernel\Contracts\AccessToken;

class MyAccessToken implements AccessToken
{
    public function getToken(): string
    {
        try {
            return MiniApp::getInstance()->getAccessToken();
        } catch (\Exception $e) {
            throw new \Exception('获取AccessToken失败');
        }
    }

    public function toQuery(): array
    {
        return ['access_token' => $this->getToken()];
    }
}
